const express = require('express')
const router = express.Router()


/**
 * 默认新增用户页面
 */
router.get("/",(req, res, next) => {
    // res.render('add-user', { title: '新增用户' });
    res.render('/login.html', { title: '用户登录' });
})

router.post("/add-one-user.do",(req, res, next) => {
    console.log("新增用户！")
    const {query,params,body,path} = req
    const {username,password} = body
    console.log(`path:${path} ===  username:${username} ===  password:${password}`)
    // res.setHeader("Content-Type","application/json;charset=utf-8;")
    res.json({
        code:200,
        message:"新增用户成功！",
        data:{
            id:0
        }
    })
    res.end()
})
router.get('/update-one-user.do/:id?',(req, res, next) => {
    res.render('index', { title: '更新新用户！！！' });
})
router.get('/delete-one-user.do/:id?',(req, res, next) => {
    res.render('index', { title: '删除一个新用户！！！' });
})
router.get('/get-one-user.do/:id?',(req, res, next) => {
    res.render('index', { title: '获取一个新用户！！！' });
})
router.get('/get-all-users.do',(req, res, next) => {
    res.render('index', { title: '获取所有新用户！！！' });
})


module.exports = router;

